home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 86 / PIWD86.iso / pc / contents / dreamweaver / software / dwmx2004.exe / Disk1 / data1.cab / Configuration_En / Commands / delete set.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  2.1 KB  |  72 lines

  1. // Copyright 2000, 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. //*************** GLOBALS *****************
  4. var FILE_CONFIG_PATH = dw.getConfigurationPath();
  5. var FILE_CUSTOM_SET = FILE_CONFIG_PATH + "/Menus/Custom Sets";
  6.  
  7. //******************* API **********************
  8. function commandButtons()
  9. {
  10.    return new Array( BTN_Delete,  "cmdDelete()"
  11.                    , MM.BTN_Cancel, "cmdCancel()");
  12. }
  13.  
  14. function cmdDelete()
  15. {
  16.   var deleteSetName;
  17.   deleteSetName = LIST_SETS.get();
  18.   // check to see if it is the active set : argument passed by callCommand
  19.   if (deleteSetName.indexOf(LABEL_ActiveSet) == -1)
  20.   {
  21.     if (DWfile.remove(FILE_CUSTOM_SET + "/" + deleteSetName + ".xml"));
  22.       MM.commandReturnValue = true;
  23.     window.close();
  24.   }
  25.   else
  26.     alert(MSG_CannotDeleteActiveSet);
  27. }
  28.  
  29. function cmdCancel()
  30. {
  31.   window.close();
  32. }
  33. //***************** LOCAL FUNCTIONS  ******************
  34.  
  35. function initializeUI()
  36.   var setArray = new Array(), activeSetName,i;  
  37.   activeSetName = MM.commandArgument;
  38.   LIST_SETS = new ListControl("customSetsList");
  39.   
  40.   setArray = getSimpleName(getCustomSetList("custom"));
  41.   // find the active set and change label (active set)
  42.   for (i=0; i<setArray.length;i++)
  43.   {
  44.     if (setArray[i] == activeSetName)
  45.       setArray[i] += " "+LABEL_ActiveSet;
  46.   }
  47.   LIST_SETS.setAll(setArray);
  48. }
  49.  
  50. function getCustomSetList(setType)
  51. {
  52.   var fileObj, filterFunction;
  53.   fileObj = new File(FILE_CUSTOM_SET);
  54.   if (setType == "factory")
  55.     filterFunction =  new Function("x", "return (x.isFile()) && (x.getAttributes() == 'R') && (x.getExtension()== 'xml');");
  56.   else
  57.     filterFunction =  new Function("x", "return (x.isFile()) && (x.getAttributes() != 'R') && (x.getExtension()== 'xml');");
  58.   return fileObj.listFolder(filterFunction);
  59. }
  60.  
  61. function getSimpleName(filenameArray)
  62. {
  63.   var i;
  64.   for (i=0;i<filenameArray.length;i++)
  65.   {
  66.     if (filenameArray[i].lastIndexOf(".xml") == filenameArray[i].length-4) 
  67.       filenameArray[i] = filenameArray[i].replace(/.xml/,""); 
  68.   }
  69.   return filenameArray;
  70. }
  71.